var t = getApp();

Page({
    data: {
        active: 0,
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        info: {},
        loading: !1
    },
    onLoad: function(t) {
        this.getUserData(), this.getData();
    },
    getUserData: function() {
        var a = this, e = t.getNetAddresss("plugin.consume-reward.frontend.member.getMemberDetail");
        t._getNetWork({
            url: e,
            success: function(e) {
                var n = e.data;
                if (1 != n.result) return t.tips(n.msg);
                console.log(n), n.data.plugin_name && wx.setNavigationBarTitle({
                    title: n.data.plugin_name
                }), a.setData({
                    info: n.data
                });
            }
        });
    },
    swichTabTItem: function(t) {
        this.setData({
            loading: !1,
            active: t.detail.index,
            page: 1,
            list: []
        }), this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (!(this.data.current_page >= this.data.last_page)) {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), this.getMore();
        }
    },
    gotoDetails: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageH/income/consumeReward/consumeDetails/consumeDetails?id=" + a
        });
    },
    gotoMessage: function() {
        this.setData({
            "info.message_count": 0
        }), wx.navigateTo({
            url: "/packageH/income/consumeReward/consumeMessage/consumeMessage"
        });
    },
    onShareAppMessage: function() {},
    getData: function() {
        wx.showLoading({
            title: "加载中"
        });
        var a = this, e = t.getNetAddresss("plugin.consume-reward.frontend.member.getMemberOrder");
        t._postNetWork({
            url: e,
            data: {
                state: this.data.active,
                page: this.data.page
            },
            success: function(t) {
                var e = t.data;
                wx.hideLoading({
                    success: function(t) {}
                }), 1 == e.result ? a.setData({
                    loading: !0,
                    listData: e.data.data,
                    current_page: e.data.current_page,
                    last_page: e.data.last_page
                }) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getMore: function() {
        wx.showLoading({
            title: "加载中"
        });
        var a = this, e = t.getNetAddresss("plugin.consume-reward.frontend.member.getMemberOrder");
        t._postNetWork({
            url: e,
            data: {
                state: this.data.active,
                page: this.data.page
            },
            success: function(t) {
                var e = t.data;
                wx.hideLoading({
                    success: function(t) {}
                }), 1 == e.result ? a.setData({
                    listData: a.data.listData.concat(e.data.data),
                    current_page: e.data.current_page,
                    last_page: e.data.last_page
                }) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    }
});